package com.dengqi.mymodule.activity.network.activity;

import android.os.Bundle;
import android.view.View;

import com.dengqi.mymodule.R;
import com.dengqi.mymodule.activity.network.bean.AccountBean;
import com.dengqi.mymodule.activity.network.bean.AccountBusinessBean;
import com.dengqi.mymodule.activity.network.bean.CityBean;
import com.dengqi.mymodule.activity.network.module.AccountContract;
import com.dengqi.mymodule.activity.network.module.AccountPresenter;
import com.dengqi.mymodule.activity.network.module.CityContract;
import com.dengqi.mymodule.activity.network.module.CityPresenter;
import com.dengqi.mymodule.activity.network.module.CommonContract;
import com.dengqi.mymodule.activity.network.module.CommonPresenter;
import com.module.retrofit.utils.ToastUtil;
import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;

import java.util.List;


/**
 * @Author: dengqi
 * @CreateDate: 2020-10-15 19:49
 * @Description:
 */
public class LoginActivity extends RxAppCompatActivity implements
        AccountContract.LoginView,
        CommonContract.SmsView,
        AccountContract.AccountTypeView,
        AccountContract.EditPasswordView,
        CityContract.CityView,
        AccountContract.LogoutView {

    private AccountPresenter accountPresenter;
    private CommonPresenter commonPresenter;
    private CityPresenter cityPresenter;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_login);
        accountPresenter = new AccountPresenter(this);
        commonPresenter = new CommonPresenter(this);
        cityPresenter = new CityPresenter(this);

    }

    public void onBtn1(View view) {
        commonPresenter.sendCaptcha(this);
    }

    public void onBtn2(View view) {
        accountPresenter.login(this);
    }

    public void onBtn3(View view) {
        accountPresenter.getAccountType(this);
    }

    public void onBtn4(View view) {
        accountPresenter.login2(this, this);
    }

    public void onBtn5(View view) {
        accountPresenter.editPassword(this);
    }

    public void onBtn6(View view) {
        cityPresenter.getCityLists(this);
    }

    public void onBtn7(View view) {
        accountPresenter.logout(this);
    }

    @Override
    public String getAccount() {
        return "13916379354";
    }

    @Override
    public String getPassWord() {
        return "123456";
    }

    @Override
    public String getRePassWord() {
        return "123456";
    }

    @Override
    public String getCaptcha() {
        return "123456";
    }

    @Override
    public String getLoginType() {
        return "1";
    }

    @Override
    public String getPhone() {
        return getAccount();
    }

    @Override
    public void onLogin(AccountBean result) {
        ToastUtil.showToast("toMainActivity");
    }

    @Override
    public void onSendCaptcha() {
        ToastUtil.showToast("验证码已发送");
    }

    @Override
    public void onGetAccountType(AccountBusinessBean result) {
        ToastUtil.showToast("选择分店："+result.getUserType());
    }

    @Override
    public void onEditPassword() {
        ToastUtil.showToast("修改成功");
    }

    @Override
    public void onCityLists(List<CityBean> result) {
        ToastUtil.showToast("城市列表"+result.size());
    }

    @Override
    public void onLogout() {
        ToastUtil.showToast("登出成功");
    }
}
